// db.ts
import Dexie, { type EntityTable } from 'dexie';



const db = new Dexie('DataBase') as Dexie & {
    device: EntityTable<
        device,
        'id' // primary key "id" (for the typings only)
    >;
    testTube: EntityTable<
        testTube,
        'id' // primary key "id" (for the typings only)
    >;
    testTubeHistory: EntityTable<
        testTube,
        'id' // primary key "id" (for the typings only)
    >;
    info: EntityTable<
        info,
        'id' // primary key "id" (for the typings only)
    >;
    nurse: EntityTable<
        nurse,
        'id' // primary key "id" (for the typings only)
    >;
    whites: EntityTable<
        white,
        'id' // primary key "id" (for the typings only)
    >;
    error: EntityTable<
        error,
        'id' // primary key "id" (for the typings only)
    >;
    disinfect: EntityTable<
        disinfect,
        'id' // primary key "id" (for the typings only)
    >;

    retryTasks: EntityTable<
        RetryTask,
        'id' // primary key "id" (for the typings only)
    >;
};

// Schema declaration:
db.version(1).stores({
    device: '++id',  // ++ 表示自增主键
    testTube: '++id,info', // ++ 表示自增主键
    testTubeHistory: '++id,info,outTime', // ++ 表示自增主键
    info: '++id,info,eventTime', // ++ 表示自增主键
    nurse: '++id,info', // ++ 表示自增主键
    whites: '++id', // ++ 表示自增主键
    error: '++id', // ++ 表示自增主键
    disinfect: '++id', // ++ 表示自增主键
    retryTasks: '++id, time, url'
});

// export type { device, testTube };
export { db };